package com.example.activiti.runserver;

import java.util.Map;
import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.TaskService;
import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.JavaDelegate;
import org.activiti.engine.task.Task;
import org.springframework.stereotype.Service;
import com.example.activiti.common.SpringBeanUtil;

@Service
public class RunserviceAbstract implements JavaDelegate {
	
	@Override
	public void execute(DelegateExecution execution) {
		ProcessEngine ProcessEngine = ProcessEngines.getDefaultProcessEngine();
		TaskService taskService = ProcessEngine.getTaskService();
		System.out.println("这是一首简单的小情歌！");
		String instanceId = execution.getProcessInstanceId();
		Task task = taskService.createTaskQuery()
				.processInstanceId(instanceId)
				.singleResult();
		String taskId = task.getId();
		Map<String, Object> paramMap = taskService.getVariables(taskId);
		Runservice runservice = SpringBeanUtil.getBean("testTask");
		runservice.myTaTask(paramMap);
	}
}
